<template>
  <el-tag :type="type" size="small">{{ tagName }}</el-tag>
</template>

<script>
export default {
  props: {
    state: {
      type: String,
      default: "",
    },
    name: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      tagTypeMap: new Map([
        ["订单状态", { 1: "success", 2: "danger", 3: "warning", 4: "info" }],
        ["订单类型", { 1: "", 2: "danger" ,3: "warning", 4: "success"}],
        ["订单操作", { 1: "info", 2: "danger", 3: "warning", 4: "success" }],
        ["发货状态", { 1: "warning", 2: "success" }],
      ]),
      tagNameMap: new Map([
        ["订单状态", { 1: "普通订单", 2: "退款订单", 3: "售后订单" }],
        ["订单类型", { 1: "正式订单", 2: "运营补单", 3: "个人",4: "企业",5: "保外零售",6: "线下零售"}],
        ["订单操作", { 1: "未分组", 2: "延时报备", 3: "按时发货",4: "报备完成" }],
        ["发货状态", { 1: "未发货", 2: "已发货" }],
      ]),
    };
  },
  computed: {
    // 根据state值指定type类型
    type: function () {
      const tagInfo = this.tagTypeMap.get(this.name);
      return tagInfo ? tagInfo[this.state] : "";
    },
    // 根据name和state判断tag的内容
    tagName: function () {
      if(this.state == '') return '空'
      const tagInfo = this.tagNameMap.get(this.name);
      // console.log(tagInfo,this.name,this.state)
      if(this.state == '个人') return tagInfo ? tagInfo[3] : "";
      if(this.state == '企业') return tagInfo ? tagInfo[4] : "";
      if(this.state == '保外零售') return tagInfo ? tagInfo[5] : "";
      if(this.state == '线下零售') return tagInfo ? tagInfo[6] : "";
      // if(this.state == null) return "无";
      return tagInfo ? tagInfo[this.state] : "";
    },
  },
  created() {},
  mounted() {},
  watch: {},
  methods: {},
  components: {},
};
</script>

<style scoped lang="less"></style>
